import { send } from '@/serves/request'
// import { webApi, pythonApi, downloadFile } from '@/serves/api.config'
import { pengWeiApp } from '@/serves/prefixConfig'

// 上传 返回text/event-stream
export const uploadFileUrl = `${pengWeiApp.pengWeiWebApi}/service-dome/doc/upload`

export function upload(data: any) {
	return send({
		url: `${pengWeiApp.pengWeiWebApi}/service-dome/doc/upload`,
		headers: {
			'Content-Type': 'multipart/form-data',
			customResponse: true,
		},
		method: 'post',
		data,
	})
}

// 上传文件-python服务
export function uploadPython(data: any) {
	return send({
		url: `${pengWeiApp.pengWeiPythonApi}/service-dome/api/upload_file`,
		headers: {
			'Content-Type': 'multipart/form-data',
			customResponse: true,
		},
		method: 'post',
		data,
	})
}

// // 下载文件
// export function downloadFileArraybuffer(fileName: string) {
// 	return send({
// 		url: `${downloadFile}/download/${fileName}`,
// 		headers: {
// 			customResponse: true,
// 		},
// 		method: 'get',
// 		responseType: 'arraybuffer',
// 	})
// }

// 下载Python生成的xlsx文件
export function downloadFilePython(params: any) {
	return send({
		url: `${pengWeiApp.pengWeiPythonApi}/service-dome/api/download_file/`,
		headers: {
			customResponse: true,
		},
		params,
		method: 'get',
		responseType: 'arraybuffer',
	})
}
